package domain;

/**
 *
 * @author shaigi
 */
public class Flag {
    
    private SquareFree  _square;
    private boolean     _taken;
    private int         _value;

    //constructor
    public Flag(SquareFree square, int value) {
        this._square    = square;
        this._taken     = false;
        this._value     = value;
    }
    
    //Copy Constructor
    public Flag(Flag other){
    	//this._square=new SquareFree(other._square);
    	this._square = null;		//This null will be changed in ANode, CloneFlags()
    	this._taken  = other._taken;
    	this._value  = other._value;
    }
    

    public int getValue() {
        return _value;
    }

    public boolean isTaken() {
        return _taken;
    }

    public void setTaken(boolean taken) {
        this._taken = taken;
    }

    public Square getSquare() {
        return _square;
    }
    
    public void setSquare(Square place){
    	if (place instanceof SquareFree) {
			this._square = (SquareFree) place;
		}
    	else{
    		System.err.println("Flag: setSquare: trying to place flag in non squareFree location");
    	}
    }//end of setSquare
    
    public boolean equals(Flag other){
        return this._square.equals(other.getSquare());
    }
    @Override
    public String toString() {
    	String taken = "";
    	if (isTaken())
    		taken = "is taken ";
    	return "Flag: "+ taken + this._square + "  value: " + this._value;
    }
    
}
